home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / compre1a / msagent.frm < prev    next >
Text File  |  1999-08-29  |  23KB  |  656 lines

  1. VERSION 5.00
  2. Object = "{F5BE8BC2-7DE6-11D0-91FE-00C04FD701A5}#2.0#0"; "AGENTCTL.DLL"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Begin VB.Form Form1 
  5.    Caption         =   "Form1"
  6.    ClientHeight    =   3195
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   4680
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3195
  12.    ScaleWidth      =   4680
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin MSComctlLib.StatusBar StatusBar1 
  15.       Align           =   2  'Align Bottom
  16.       Height          =   315
  17.       Left            =   0
  18.       TabIndex        =   1
  19.       Top             =   2880
  20.       Width           =   4680
  21.       _ExtentX        =   8255
  22.       _ExtentY        =   556
  23.       Style           =   1
  24.       _Version        =   393216
  25.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  26.          NumPanels       =   1
  27.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  28.          EndProperty
  29.       EndProperty
  30.    End
  31.    Begin VB.CommandButton Command1 
  32.       Caption         =   "Command1"
  33.       Height          =   615
  34.       Left            =   1260
  35.       TabIndex        =   0
  36.       Top             =   1080
  37.       Width           =   1455
  38.    End
  39.    Begin AgentObjectsCtl.Agent Agent 
  40.       Left            =   360
  41.       Top             =   300
  42.       _cx             =   847
  43.       _cy             =   847
  44.    End
  45. End
  46. Attribute VB_Name = "Form1"
  47. Attribute VB_GlobalNameSpace = False
  48. Attribute VB_Creatable = False
  49. Attribute VB_PredeclaredId = True
  50. Attribute VB_Exposed = False
  51. Option Explicit
  52.  
  53. Dim Genie As IAgentCtlCharacter
  54. Dim Robby As IAgentCtlCharacter
  55. Dim Merlin As IAgentCtlCharacter
  56. Dim LoadRequest(3)
  57. Dim GetRequest(8)
  58. Dim GenieRequest As IAgentCtlRequest
  59. Dim RobbyRequest As IAgentCtlRequest
  60. Dim MerlinRequest As IAgentCtlRequest
  61. Dim DatapathType As String
  62. Dim CenterX As Integer, CenterY As Integer
  63. Dim RobbyDelayed As Boolean
  64. Dim RobbyLoaded As Boolean
  65. Dim MerlinLoaded As Boolean
  66. Dim RobbyShowFailed As Boolean
  67. Dim MerlinShowFailed As Boolean
  68.  
  69. Private Sub Agent_Click(ByVal CharacterID As String, ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Integer, ByVal Y As Integer)
  70.     If Button = 1 Then
  71.  
  72.         'If we have already loaded Robby, but his Showing state animation failed
  73.             If RobbyLoaded = True And RobbyShowFailed = True Then
  74.                 ' Apologize
  75.                 Genie.Play "Greet"
  76.                 Genie.Speak "Yes, O Great One. I will attempt to summon Robby again.|As you wish, my master."
  77.             
  78.                 ' Try again
  79.                 Set GetRequest(6) = Robby.Get("state", "showing, speaking")
  80.  
  81.         ' Otherwise, if we have already loaded Merlin, but his Showing state animation failed
  82.         ElseIf MerlinLoaded = True And MerlinShowFailed = True Then
  83.  
  84.                 ' Apologize
  85.                 Genie.Speak "Yes, O Noble One. I will attempt to summon Merlin again.|Yes, Master. I will see if I can rouse the wizened one."
  86.                 
  87.                 ' Try again
  88.                 Set GetRequest(7) = Merlin.Get("state", "showing, speaking")
  89.                             
  90.  
  91.         Else ' We haven't loaded either character yet, so just ignore the click.
  92.             Exit Sub
  93.         End If
  94.     End If
  95. End Sub
  96.  
  97. Private Sub Agent_RequestComplete(ByVal Request As Object)
  98.     Select Case Request
  99.  
  100.         Case LoadRequest(1)
  101.             
  102.             If Request.Status <> 0 Then
  103.                 ' If genie's character data fails to load post a message
  104.                 StatusBar1.SimpleText = "Genie character failed to load."
  105.  
  106.                 MsgBox "Unable to load the Genie character. Please try refreshing this page."
  107.  
  108.             Else
  109.                 StatusBar1.SimpleText = "Genie character successfully loaded."
  110.  
  111.                 ' Create a reference to the character
  112.                 Set Genie = Agent.Characters("genie")
  113.  
  114.                 ' Load the character's Showing and Speaking state animations
  115.                 Set GetRequest(1) = Genie.Get("state", "showing,speaking")
  116.                 
  117.                 StatusBar1.SimpleText = "Now loading Genie's Showing and Speaking state animations."
  118.                 
  119.             End If
  120.  
  121.         Case LoadRequest(2)
  122.  
  123.             If Request.Status <> 0 Then
  124.                 StatusBar1.SimpleText = "Robby character failed to load."
  125.                 RobbyLoaded = False
  126.                 Genie.Speak "Uh oh, Robby failed to load."
  127.                 Genie.Speak "Try refreshing this page."
  128.                 
  129.             Else
  130.                 StatusBar1.SimpleText = "Robby character successfully loaded."
  131.                 RobbyLoaded = True
  132.                 Set Robby = Agent.Characters("robby")
  133.                 Set GetRequest(6) = Robby.Get("state", "showing,speaking")
  134.                 
  135.                 StatusBar1.SimpleText = "Loading Robby's Showing and Speaking state animations."
  136.                 
  137.             End If
  138.  
  139.         Case LoadRequest(3)
  140.             
  141.             If Request.Status <> 0 Then
  142.                 StatusBar1.SimpleText = "Merlin character failed to load."
  143.                 MerlinLoaded = False
  144.                 Genie.Play "Greet"
  145.                 Genie.Speak "Ten thousand pardons, O Merciful One. Merlin was not available."
  146.                 Genie.Speak "When we're done, you can try refreshing this page and maybe he'll show up next time."
  147.                 
  148.                 If RobbyLoaded = True And RobbyShowFailed = False Then
  149.                     Robby.Hide
  150.  
  151.                 End If
  152.  
  153.                 SayGoodbye
  154.                 
  155.             Else
  156.                 StatusBar1.SimpleText = "Merlin character successfully loaded."
  157.                 MerlinLoaded = True
  158.                 Set Merlin = Agent.Characters("merlin")
  159.                 Set GetRequest(7) = Merlin.Get("state", "showing,speaking", False)
  160.                 Merlin.Get "animation", "blink", False
  161.  
  162.                 StatusBar1.SimpleText = "Loading Merlin's Showing and Speaking state animations."
  163.             
  164.             End If
  165.  
  166.  
  167.         Case GetRequest(1) 'Request to load Genie's Showing and Speaking state animations
  168.  
  169.             If Request.Status = 0 Or DatapathType = "UNC" Then
  170.  
  171.                 StatusBar1.SimpleText = "Genie's Showing and Speaking state animations loaded."
  172.                 
  173.                 Genie.Get "animation", "greet", False
  174.  
  175.                 ' If the animation loaded, start the intro
  176.                 StartIntro
  177.                 
  178.             Else
  179.                 StatusBar1.SimpleText = "Genie's Showing and Speaking state animations failed to load."
  180.                 
  181.                 MsgBox "Unable to load Genie's Showing and Speaking animations. Try refreshing the page."
  182.                 
  183.             End If
  184.  
  185.         Case GetRequest(2) 'Request to load Genie's LookLeft, GreetReturn, Blink animations
  186.             
  187.             If Request.Status = 0 Or DatapathType = "UNC" Then
  188.  
  189.                 StatusBar1.SimpleText = "Genie's LookLeft, GreetReturn, and Blink animations loaded."
  190.  
  191.                 Genie.Play "RestPose"
  192.  
  193.             Else
  194.                 StatusBar1.SimpleText = "Genie's LookLeft, GreetReturn, and Blink animations failed to load."
  195.  
  196.             End If
  197.  
  198.             ' Now process Genie's intro of Robby
  199.             GenieIntro
  200.  
  201.         Case GetRequest(3) 'Request to load Robby's Wave animation
  202.             
  203.             If Request = 0 Or DatapathType = "UNC" Then
  204.  
  205.                 StatusBar1.SimpleText = "Robby's Wave animation loaded."
  206.  
  207.             Else
  208.                 StatusBar1.SimpleText = "Robby's Wave animaton failed to load."
  209.  
  210.             End If
  211.  
  212.             RobbyIntro
  213.  
  214.  
  215.         Case GetRequest(4) 'Request to load Robby's LookRight animations
  216.  
  217.             If Request.Status = 0 Or DatapathType = "UNC" Then
  218.  
  219.                 StatusBar1.SimpleText = "Robby's LookRight animations loaded"
  220.  
  221.             Else
  222.                 StatusBar1.SimpleText = "Robby's LookRight animation failed to load."
  223.  
  224.             End If
  225.  
  226.             RobbyExpl